package com.util.annotate.demo.service;

import com.util.annotate.demo.service.HrsConfigFactory;
import com.util.annotate.demo.service.HrsConfigService;

import java.io.FileInputStream;
import java.io.InputStream;

/**
 * 动态代理+算定义注解
 * https://blog.csdn.net/Java_HuiLong/article/details/85649165
 */
public class DemoTest {
    public static void main(String[] args) {

        try {

            // 文件地址可以直接copypath
            InputStream fileInputStream = new FileInputStream("src/main/resources/application.yml");

            HrsConfigService configService = HrsConfigFactory.readProperties(fileInputStream);
            if (configService == null){
                return;
            }
            Integer port = configService.getPort();
            String url = configService.getUrl();
            String userName = configService.getUserName();
            String pwd = configService.getPwd();
            Boolean off = configService.getOff();
            String format = String.format("读取配置信息，url: %s, username: %s, password: %s, port :%s, 开关：%s",
                    url, userName, pwd, port, off);

            System.out.println( format );
        } catch (Exception e) {
            System.out.println("文件不存在");
        }

    }

}
